﻿using BLL;
using DTO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BONGDA
{
    public partial class frmTopScorers : Form
    {
        public frmTopScorers()
        {
            InitializeComponent();
        }

        private void frmTopScorers_Load(object sender, EventArgs e)
        {
            DataTable dtCauThu = CauThu_BLL.SelectTopScores();
            DataTable table;
            DataColumn column;
            DataRow row;

            // Load danh sach doi bong
            table = new DataTable("DoiBong");

            column = new DataColumn();
            column.DataType = Type.GetType("System.Int32");
            column.ColumnName = "STT";
            column.AutoIncrement = false;
            //column.Caption = "Logo";
            column.ReadOnly = false;
            column.Unique = false;
            // Add the column to the table.
            table.Columns.Add(column);

            
            column = new DataColumn();
            column.DataType = Type.GetType("System.String");
            column.ColumnName = "TenCauThu";
            column.AutoIncrement = false;
            //column.Caption = "Đội bóng";
            column.ReadOnly = false;
            column.Unique = false;
            // Add the column to the table.
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = Type.GetType("System.Int32");
            column.ColumnName = "BanThang";
            column.AutoIncrement = false;
            //column.Caption = "Điểm";
            column.ReadOnly = false;
            column.Unique = false;
            // Add the column to the table.
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = Type.GetType("System.String");
            column.ColumnName = "TenDoiBong";
            column.AutoIncrement = false;
            //column.Caption = "Đội bóng";
            column.ReadOnly = false;
            column.Unique = false;
            // Add the column to the table.
            table.Columns.Add(column);

            for (int i = 0; i < dtCauThu.Rows.Count; i++)
            {
                row = table.NewRow();
                row["STT"] = i + 1;
                row["TenCauThu"] = dtCauThu.Rows[i]["TenCauThu"];
                row["BanThang"] = dtCauThu.Rows[i]["BanThang"];
                DoiBong_DTO dto = DoiBong_BLL.SelectByID(Convert.ToInt32(dtCauThu.Rows[i]["MaDoiBong"]));
                row["TenDoiBong"] = dto.TenDoiBong;
                table.Rows.Add(row);
            }
            dgvTopScore.DataSource = table; // Xong table  doi bong
        }
    }
}
